import java.util.Arrays;

public class Test {
        public static int removeDuplicates(int[] nums) {
            if(nums.length == 0){
                return 0;

            }
            int left = 0;
            int right = 1;
            while(right < nums.length){
                if(nums[left] == nums[right]){
                    nums[left] = nums[right];
                    right++;
                }
                if(nums[left] != nums[right]){
                    nums[left + 1] = nums[right];
                    left++;
                    right++;
                }

            }
            /*int [] temp = new int[left + 1];
            for(int i = 0 ; i < temp.length;i++){
                temp[i] = nums[i];
            }*/
            /*for (int i = left + 1; i < nums.length; i++) {
                nums[left + 1] = 0;
            }*/
            return left +1;

        }

    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,2,2,3,3,4};
        removeDuplicates(nums);
        System.out.println(Arrays.toString(nums));


    }
}
